const router = require('koa-joi-router')
const picture = router()
const Joi = router.Joi
const pictureCtrl = require('../controller/picture')
picture.prefix('/picture')
picture.route({
  method: 'get',
  path: '/getList',
  validate: {
    query: {
      page: Joi.number().default(1),
      page_size: Joi.number().default(20)
    }
  },
  handler: [pictureCtrl.getList]
})
picture.route({
  method: 'get',
  path: '/getPicById',
  validate: {
    query: {
      id: Joi.number().default(0)
    }
  },
  handler: [pictureCtrl.getById]
})
picture.route({
  method: 'get',
  path: '/getRelateByPicId',
  validate: {
    query: {
      page: Joi.number().default(1),
      page_size: Joi.number().default(20),
      pid: Joi.number().default(0)
    }
  },
  handler: [pictureCtrl.getRelateByPicId]
})
picture.route({
  method: 'get',
  path: '/getListInPicTag',
  validate: {
    query: {
      page: Joi.number().default(1),
      page_size: Joi.number().default(20),
      ids: Joi.array().default([0]),
      type: Joi.string().default('')
    }
  },
  handler: [pictureCtrl.getListInPicTag]
})
picture.route({
  method: 'get',
  path: '/getListByTagId',
  validate: {
    query: {
      page: Joi.number().default(1),
      page_size: Joi.number().default(20),
      tid: Joi.number().default(0)
    }
  },
  handler: [pictureCtrl.getListByTagId]
})

picture.route({
  method: 'get',
  path: '/getLatestTagList',
  handler: [pictureCtrl.getLatestTagList]
})


picture.route({
  method: 'get',
  path: '/download',
  validate: {
    query: {
      name: Joi.string().default('')
    }
  },
  handler: [pictureCtrl.download]
})

module.exports = picture
